package jcu.mobile.library.namespace;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.app.Activity;
import android.view.View.OnClickListener;
import com.parse.Parse;
import com.parse.ParseObject;


public class AddNewsActivity extends Activity {
	
	EditText title;
	EditText description;
	Button insertNews;
	Button resetText;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		Parse.initialize(this, "1GlGZQ1XWU34mHgFyDHZiZRr6HTTSWOZo2nSAowy", "GKVclKTd6TIPxLVPPbDiyvzAMoWA2XLf4ZdZYFwI");
		super.onCreate(savedInstanceState);
        setContentView(R.layout.insert_news);
		
        title = (EditText) findViewById(R.id.textTitle);
        description = (EditText) findViewById(R.id.textDesc);
   
		insertNews = (Button) findViewById(R.id.insertNewsBtn);
		resetText = (Button) findViewById(R.id.reset);
		
		insertNews.setOnClickListener(new OnClickListener() {
        	
        	public void onClick(View v) {
        		
        		ParseObject newsTable = new ParseObject("News");
        		newsTable.put("Title", title.getText().toString());
        		newsTable.put("Description", description.getText().toString());
        		newsTable.saveInBackground();

        		title.setText("");
        		description.setText("");
        	}
        });
		
		
		resetText.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				title.setText("");
				description.setText("");
			}
		});
		
	}
	
}
